/**
 * 
 */
package com.sx.article.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sx.article.dao.IKeyWordDao;
import com.sx.article.entity.KeyWordAndArticleUnionEntity;
import com.sx.article.entity.KeyWordsEntity;
import com.sx.core.BaseDao;

/**
 * @author Administrator
 *关键字、索引字Dao连接类
 */
public class KeyWordDao extends BaseDao implements IKeyWordDao {
	private Log log = LogFactory.getLog(this.getClass());
	
	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#deleteKeyWordsByArticleId(java.lang.Integer)
	 */
	public boolean deleteKeyWordsByArticleId(Integer aid) {
		// TODO Auto-generated method stub
		boolean flag = false;
		try {
			flag = super.delInfo(aid, "KeyWords.deleteKeyWordsByArticleId");
			flag = true;
		} catch (Exception e) {
			log.error("添加KeyWord信息关联失败Dao",e);
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#findKeyWords(com.sx.article.entity.KeyWordsEntity)
	 */
	public List<KeyWordsEntity> findKeyWords(KeyWordsEntity keyword,String queryname) {
		// TODO Auto-generated method stub
		List<KeyWordsEntity> list = new ArrayList<KeyWordsEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList(queryname, keyword);
		} catch (Exception e) {
			// TODO: handle exception
			log.error("获取索引字信息",e);
		}
		return list;
	}

	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#findKeyWordsCount(com.sx.article.entity.KeyWordsEntity)
	 */
	public String findKeyWordsCount(KeyWordsEntity keyword,String queryname) {
		String count = null;
		try {
			count = (String)super.getSqlMapClientTemplate().queryForObject(queryname, keyword);
		} catch (Exception e) {
			// TODO: handle exception
			log.error("获取索引字信息数量",e);
		}
		return count;
	}
	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#deleteKeyWords(com.sx.article.entity.KeyWordsEntity)
	 */
	public boolean deleteKeyWords(KeyWordsEntity keyword) {
		boolean flag = false;
		try {
			flag = super.delInfo(keyword, "KeyWords.deleteKeyWords");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("删除关键字",e);
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#findKeyWords(com.sx.article.entity.KeyWordsEntity)
	 */
	public List<KeyWordsEntity> findKeyWords(KeyWordsEntity keyword) {
		// TODO Auto-generated method stub
		List<KeyWordsEntity> list = new ArrayList<KeyWordsEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("KeyWords.findKeyWords", keyword);
		} catch (Exception e) {
			// TODO: handle exception
			log.error("获取索引字信息",e);
		}
		return list;
	}

	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#findKeyWordsCount(com.sx.article.entity.KeyWordsEntity)
	 */
	public String findKeyWordsCount(KeyWordsEntity keyword) {
		String count = null;
		try {
			count = (String)super.getSqlMapClientTemplate().queryForObject("KeyWords.findKeyWordsCount", keyword);
		} catch (Exception e) {
			// TODO: handle exception
			log.error("获取索引字信息数量",e);
		}
		return count;
	}

	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#addKeyWord(com.sx.article.entity.KeyWordsEntity)
	 */
	public Integer addKeyWord(KeyWordsEntity keyword) {
		// TODO Auto-generated method stub
		Integer id = null;
		try {
			id = super.addInfo(keyword, "KeyWords.addKeyWord");
		} catch (Exception e) {
			log.error("添加KeyWord信息关联失败Dao",e);
		}
		return id;
	}

	/* (non-Javadoc)
	 * @see com.sx.article.dao.IKeyWordDao#addKeyWordAndArticeUnion(com.sx.article.entity.KeyWordsEntity)
	 */
	public Integer addKeyWordAndArticeUnion(KeyWordAndArticleUnionEntity kwe) {
		// TODO Auto-generated method stub
		Integer id = null;
		try {
			id = super.addInfo(kwe, "KeyWords.addKeyWordAndArticeUnion");
		} catch (Exception e) {
			log.error("添加KeyWord和文章信息关联失败Dao",e);
		}
		return id;
	}

}
